﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Zsea.HTML
{
    public class NodeCollection:List<Node>
    {
        // Fields
        //private List<Node> _item = new List<Node>();
        internal Node _Parent;

        // Methods
        public new void Add(Node item)
        {
            base.Add(item);
            item.Parent = this._Parent;
        }

        //public List<Node> FindAll(Predicate<Node> match)
        //{
        //    return this._item.FindAll(match);
        //}

        public List<Node> FindAll(string name)
        {
            return base.FindAll(delegate(Node o)
            {
                return o.Name.ToUpper() == name.ToUpper();
            });
        }

        public Node SingleNode(Predicate<Node> match)
        {
            return base.Find(match);
        }

        public override string ToString()
        {
            return string.Format("Count={0}", base.Count);
        }

        // Properties
        //public int Count
        //{
        //    get
        //    {
        //        return this._item.Count;
        //    }
        //}

        public Node this[string name]
        {
            get
            {
                return base.Find(delegate(Node o)
                {
                    return o.Name.ToUpper() == name.ToUpper();
                });
            }
        }

        //public Node this[int index]
        //{
        //    get
        //    {
        //        return base[index];
        //    }
        //}
    }





}
